package com.qiang.util;


import com.qiang.enums.ExceptionCode;
import java.io.Serializable;
import java.util.HashMap;

/**
 * 公共返回处理
 * @param <T>
 */
public class ResultEntity<T> implements Serializable{
	
	
	private static final long serialVersionUID = -8442348611678831800L;
	private Integer code = 500;	
	private String message;
	private T modelData;
	
	public ResultEntity() {
		
	}
	
	public ResultEntity(Integer code, String message) {
		this.code = code;
		this.message = message;
		this.modelData = (T) new HashMap<>();
	}
	
	public ResultEntity(ExceptionCode exp) {
		this.code = exp.getCode();
		this.message = exp.getMessage();
		this.modelData = (T) new HashMap<>();
	}
	
	public ResultEntity(Integer code, String message, T modelData) {
		this.code = code;
		this.message = message;
		this.modelData = modelData;
	}
	
	public ResultEntity(T modelData) {
		this.code = ExceptionCode.SUCCESS.getCode();
		this.message = ExceptionCode.SUCCESS.getMessage();
		this.modelData = modelData;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getModelData() {
		return modelData;
	}

	public void setModelData(T modelData) {
		this.modelData = modelData;
	}
}


